def longestConsecutive(nums):
    if len(nums)==0: return 0
    st=set(nums)
    ans=1
    for k in st:
        if k-1 not in st:
            count=1
            while k+1 in st: 
                k+=1
                count+=1
            ans=max(ans,count)
    return ans
    
nums=[100,4,200,1,3,2]
print(longestConsecutive(nums))
